<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ modCount }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: current == '全部' }"
          @click="doSelect('全部')"
          href="javascript:;"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: current == '未完成' }"
          @click="doSelect('未完成')"
          href="javascript:;"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: current == '已完成' }"
          @click="doSelect('已完成')"
          href="javascript:;"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed">清除已完成</button>
  </footer>
</template>

<script>
export default {
  methods: {
    doSelect(status) {
      this.current = status;
      this.$emit("selChange", status);
    },
  },
  props: ["list"],
  data() {
    return {
      current: "全部",
    };
  },
  computed: {
    modCount() {
      let count = 0;
      this.list.forEach((v) => {
        if (!v.isDone) {
          count++;
        }
      });
      return count;
    },
  },
};
</script>